/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormCursos.java
 *
 * Created on 20/01/2012, 15:56:16
 */
package Formularios;

import Atributos.Curso;
import Metodos.CursoMet;
import Metodos.MinimizaTela;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;


public class FormCursos extends javax.swing.JFrame {
 private List<Curso> lista;
 MinimizaTela tela= new MinimizaTela();  
 Curso curso=new Curso();
 CursoMet cursomet=new CursoMet();
 String escolha; 
 public FormCursos() {
        try {
            
                    tela.Minimiza(1);
        } catch (SQLException ex) {
            Logger.getLogger(FormCursos.class.getName()).log(Level.SEVERE, null, ex);
        }
        initComponents();
        BufferedImage image=null;
        File imageFile=new File(".\\src\\Imagens\\logo3.png");
        try {
            image=ImageIO.read(imageFile);
            
        } catch (IOException ex) {
        }
        this.setIconImage(image);
        
//        BufferedImage image=new BufferedImage(10,10,BufferedImage.TYPE_INT_ARGB);
//        setIconImage(image);
        DesabilitaAdicionar();
        DesabilitaDeletar();
        DesabilitaEditar();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jRB_editar = new javax.swing.JRadioButton();
        jRB_adicionar = new javax.swing.JRadioButton();
        jRB_deletar = new javax.swing.JRadioButton();
        jTF_nomecurso = new javax.swing.JTextField();
        jl_descricao = new javax.swing.JLabel();
        jTF_descricaonovo = new javax.swing.JTextField();
        jTF_descricao = new javax.swing.JTextField();
        buton_adicionar = new javax.swing.JLabel();
        buton_editar = new javax.swing.JLabel();
        buton_deletar = new javax.swing.JLabel();
        jl_descricao3 = new javax.swing.JLabel();
        jl_curso3 = new javax.swing.JLabel();
        jl_curso2 = new javax.swing.JLabel();
        jCB_curso1 = new javax.swing.JComboBox();
        jCB_descricao1 = new javax.swing.JComboBox();
        jl_curso = new javax.swing.JLabel();
        jCB_descricao = new javax.swing.JComboBox();
        jCB_curso = new javax.swing.JComboBox();
        jTF_cursonovo = new javax.swing.JTextField();
        jl_descricao2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cursos");
        setBackground(new java.awt.Color(0, 0, 0));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setLayout(null);

        jSeparator1.setBackground(new java.awt.Color(255, 153, 0));
        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(170, 20, 11, 340);

        jRB_editar.setBackground(new java.awt.Color(0, 0, 0));
        buttonGroup1.add(jRB_editar);
        jRB_editar.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
        jRB_editar.setForeground(new java.awt.Color(255, 102, 0));
        jRB_editar.setText("Editar");
        jRB_editar.setFocusPainted(false);
        jRB_editar.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRB_editarItemStateChanged(evt);
            }
        });
        jPanel1.add(jRB_editar);
        jRB_editar.setBounds(6, 159, 140, 30);

        jRB_adicionar.setBackground(new java.awt.Color(0, 0, 0));
        buttonGroup1.add(jRB_adicionar);
        jRB_adicionar.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
        jRB_adicionar.setForeground(new java.awt.Color(255, 102, 0));
        jRB_adicionar.setText("Adicionar");
        jRB_adicionar.setFocusPainted(false);
        jRB_adicionar.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRB_adicionarItemStateChanged(evt);
            }
        });
        jPanel1.add(jRB_adicionar);
        jRB_adicionar.setBounds(6, 32, 150, 30);

        jRB_deletar.setBackground(new java.awt.Color(0, 0, 0));
        buttonGroup1.add(jRB_deletar);
        jRB_deletar.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
        jRB_deletar.setForeground(new java.awt.Color(255, 102, 0));
        jRB_deletar.setText("Deletar");
        jRB_deletar.setFocusPainted(false);
        jRB_deletar.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRB_deletarItemStateChanged(evt);
            }
        });
        jPanel1.add(jRB_deletar);
        jRB_deletar.setBounds(6, 279, 150, 30);

        jTF_nomecurso.setBackground(new java.awt.Color(0, 0, 0));
        jTF_nomecurso.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jTF_nomecurso.setForeground(new java.awt.Color(255, 255, 255));
        jTF_nomecurso.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTF_nomecurso.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
        jTF_nomecurso.setCaretColor(new java.awt.Color(255, 255, 255));
        jPanel1.add(jTF_nomecurso);
        jTF_nomecurso.setBounds(270, 90, 210, 25);

        jl_descricao.setBackground(new java.awt.Color(0, 0, 0));
        jl_descricao.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
        jl_descricao.setForeground(new java.awt.Color(255, 255, 255));
        jl_descricao.setText("Turma:");
        jPanel1.add(jl_descricao);
        jl_descricao.setBounds(180, 170, 118, 17);

        jTF_descricaonovo.setBackground(new java.awt.Color(0, 0, 0));
        jTF_descricaonovo.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jTF_descricaonovo.setForeground(new java.awt.Color(255, 255, 255));
        jTF_descricaonovo.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTF_descricaonovo.setToolTipText("Digite aqui uma nova descrição para o curso");
        jTF_descricaonovo.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
        jTF_descricaonovo.setCaretColor(new java.awt.Color(255, 255, 255));
        jTF_descricaonovo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTF_descricaonovoKeyReleased(evt);
            }
        });
        jPanel1.add(jTF_descricaonovo);
        jTF_descricaonovo.setBounds(390, 190, 66, 25);

        jTF_descricao.setBackground(new java.awt.Color(0, 0, 0));
        jTF_descricao.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jTF_descricao.setForeground(new java.awt.Color(255, 255, 255));
        jTF_descricao.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTF_descricao.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
        jTF_descricao.setCaretColor(new java.awt.Color(255, 255, 255));
        jTF_descricao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTF_descricaoKeyReleased(evt);
            }
        });
        jPanel1.add(jTF_descricao);
        jTF_descricao.setBounds(346, 160, 60, 25);

        buton_adicionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/butonadicionar.jpg"))); // NOI18N
        buton_adicionar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_adicionar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_adicionarMouseClicked(evt);
            }
        });
        jPanel1.add(buton_adicionar);
        buton_adicionar.setBounds(260, 290, 190, 40);

        buton_editar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/butoneditar.jpg"))); // NOI18N
        buton_editar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_editar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_editarMouseClicked(evt);
            }
        });
        jPanel1.add(buton_editar);
        buton_editar.setBounds(260, 290, 190, 40);

        buton_deletar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/butondeletar.jpg"))); // NOI18N
        buton_deletar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_deletar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_deletarMouseClicked(evt);
            }
        });
        jPanel1.add(buton_deletar);
        buton_deletar.setBounds(260, 290, 190, 40);

        jl_descricao3.setBackground(new java.awt.Color(0, 0, 0));
        jl_descricao3.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
        jl_descricao3.setForeground(new java.awt.Color(255, 255, 255));
        jl_descricao3.setText("Turma:");
        jPanel1.add(jl_descricao3);
        jl_descricao3.setBounds(190, 160, 120, 17);

        jl_curso3.setBackground(new java.awt.Color(0, 0, 0));
        jl_curso3.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
        jl_curso3.setForeground(new java.awt.Color(255, 255, 255));
        jl_curso3.setText("Curso:");
        jPanel1.add(jl_curso3);
        jl_curso3.setBounds(190, 100, 79, 17);

        jl_curso2.setBackground(new java.awt.Color(0, 0, 0));
        jl_curso2.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
        jl_curso2.setForeground(new java.awt.Color(255, 255, 255));
        jl_curso2.setText("Curso:");
        jPanel1.add(jl_curso2);
        jl_curso2.setBounds(190, 50, 79, 17);

        jCB_curso1.setBackground(new java.awt.Color(0, 0, 0));
        jCB_curso1.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jCB_curso1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCB_curso1ActionPerformed(evt);
            }
        });
        jPanel1.add(jCB_curso1);
        jCB_curso1.setBounds(300, 90, 180, 27);

        jCB_descricao1.setBackground(new java.awt.Color(0, 0, 0));
        jCB_descricao1.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jCB_descricao1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jPanel1.add(jCB_descricao1);
        jCB_descricao1.setBounds(360, 160, 60, 27);

        jl_curso.setBackground(new java.awt.Color(0, 0, 0));
        jl_curso.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
        jl_curso.setForeground(new java.awt.Color(255, 255, 255));
        jl_curso.setText("Curso:");
        jPanel1.add(jl_curso);
        jl_curso.setBounds(180, 90, 79, 17);

        jCB_descricao.setBackground(new java.awt.Color(0, 0, 0));
        jCB_descricao.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jPanel1.add(jCB_descricao);
        jCB_descricao.setBounds(210, 190, 60, 27);

        jCB_curso.setBackground(new java.awt.Color(0, 0, 0));
        jCB_curso.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jCB_curso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jCB_curso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCB_cursoActionPerformed(evt);
            }
        });
        jPanel1.add(jCB_curso);
        jCB_curso.setBounds(180, 90, 140, 27);

        jTF_cursonovo.setBackground(new java.awt.Color(0, 0, 0));
        jTF_cursonovo.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        jTF_cursonovo.setForeground(new java.awt.Color(255, 255, 255));
        jTF_cursonovo.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTF_cursonovo.setToolTipText("Digite aqui o novo nome para o curso");
        jTF_cursonovo.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
        jTF_cursonovo.setCaretColor(new java.awt.Color(255, 255, 255));
        jPanel1.add(jTF_cursonovo);
        jTF_cursonovo.setBounds(340, 90, 170, 25);

        jl_descricao2.setBackground(new java.awt.Color(0, 0, 0));
        jl_descricao2.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
        jl_descricao2.setForeground(new java.awt.Color(255, 255, 255));
        jl_descricao2.setText("Turma:");
        jPanel1.add(jl_descricao2);
        jl_descricao2.setBounds(190, 150, 120, 17);

        jPanel1.setBounds(0, 0, 530, 400);
        jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 517, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-533)/2, (screenSize.height-416)/2, 533, 416);
    }// </editor-fold>//GEN-END:initComponents

    private void jRB_adicionarItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_adicionarItemStateChanged
       DesabilitaDeletar();
       DesabilitaEditar();
       escolha=jRB_adicionar.getText();
       ChamaEscolha(escolha);
    }//GEN-LAST:event_jRB_adicionarItemStateChanged

    private void jRB_editarItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_editarItemStateChanged
if(jRB_editar.isSelected()){
        if(VerificaBD()){
DesabilitaAdicionar();
DesabilitaDeletar();
        escolha=jRB_editar.getText();
       ChamaEscolha(escolha);     
       InicializaDadosEditar();
}else{
DesabilitaAdicionar();
DesabilitaDeletar();
    JOptionPane.showMessageDialog(null, "Não ha dados a serem editados!");
     buttonGroup1.clearSelection();
}
}
    }//GEN-LAST:event_jRB_editarItemStateChanged

    private void jRB_deletarItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_deletarItemStateChanged
if(jRB_deletar.isSelected()){
   if(VerificaBD()){
       DesabilitaAdicionar();
    DesabilitaEditar();
        escolha=jRB_deletar.getText();
       ChamaEscolha(escolha);    
       InicializaDadosDeletar();
   }else{
      DesabilitaAdicionar();
    DesabilitaEditar();
    JOptionPane.showMessageDialog(null, "Não ha dados a serem excluidos!");
    buttonGroup1.clearSelection();
   }
}
    }//GEN-LAST:event_jRB_deletarItemStateChanged

private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
  
        try {
            tela.Minimiza(0);
        } catch (SQLException ex) {
            Logger.getLogger(FormCursos.class.getName()).log(Level.SEVERE, null, ex);
        }
       java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new ChamaLayout().setVisible(true);
            }
        }); 
}//GEN-LAST:event_formWindowClosed

private void buton_adicionarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_adicionarMouseClicked
 if(VerificaDadosCorretosADD()){
   curso.setNome(jTF_nomecurso.getText());
   curso.setDescrição(jTF_descricao.getText());
   if(cursomet.BuscaCursoseDescriçoesiguais(curso)){
            try {
                cursomet.AdicionaCurso(curso);
            } catch (SQLException ex) {
                Logger.getLogger(FormCursos.class.getName()).log(Level.SEVERE, null, ex);
            }
            JOptionPane.showMessageDialog(null, "Adicionado com sucesso!");
            limpaDadosAdicionar();
   }else{
       JOptionPane.showMessageDialog(null, "Este curso já existe!");
   }
}else{
    JOptionPane.showMessageDialog(null, "Dados Incorretos");
}
}//GEN-LAST:event_buton_adicionarMouseClicked

private void buton_deletarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_deletarMouseClicked
 int resp = JOptionPane.showConfirmDialog(this, "Deseja realmente excluir este curso?",
                "Confirmação", JOptionPane.YES_NO_OPTION);

        if (resp == JOptionPane.YES_NO_OPTION) {
            String a= jCB_curso1.getSelectedItem().toString();
String b= jCB_descricao1.getSelectedItem().toString();
            curso.setNome(jCB_curso1.getSelectedItem().toString());
            curso.setDescrição(jCB_descricao1.getSelectedItem().toString());
            int id=cursomet.Buscar_ID_Curso(a);
            int id_desc=cursomet.Buscar_ID_Descricao(id,b,0);
        curso.setId(id);
        curso.setId_descricao(id_desc);
            try {
                cursomet.DeletarCurso(curso);
            } catch (SQLException ex) {
                Logger.getLogger(FormCursos.class.getName()).log(Level.SEVERE, null, ex);
            }
          JOptionPane.showMessageDialog(null, "Deletado com sucesso!");  
        }
        if(VerificaBD()){
          InicializaDadosDeletar();  
        }else{
            DesabilitaDeletar();
          buttonGroup1.clearSelection();
          
        }
        
}//GEN-LAST:event_buton_deletarMouseClicked

private void jCB_curso1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCB_curso1ActionPerformed
 AtualizaDadosDeletar();
}//GEN-LAST:event_jCB_curso1ActionPerformed

private void jCB_cursoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCB_cursoActionPerformed
AtualizaDadosEditar();
}//GEN-LAST:event_jCB_cursoActionPerformed

private void buton_editarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_editarMouseClicked
if(VerificaDadosCorretosEDT()){
    if("A".equals(jTF_descricaonovo.getText()) || "B".equals(jTF_descricaonovo.getText()) || "C".equals(jTF_descricaonovo.getText()) || "D".equals(jTF_descricaonovo.getText())|| "E".equals(jTF_descricaonovo.getText())|| "F".equals(jTF_descricaonovo.getText())|| "G".equals(jTF_descricaonovo.getText())|| "H".equals(jTF_descricaonovo.getText())){
String a= jCB_curso.getSelectedItem().toString();
String b= jCB_descricao.getSelectedItem().toString();
int id=cursomet.Buscar_ID_Curso(a);
int id_desc=cursomet.Buscar_ID_Descricao(id,b,0);
curso.setDesc_ant(b);
curso.setNome_ant(a);
        curso.setNome(jTF_cursonovo.getText());
        curso.setDescrição(jTF_descricaonovo.getText());
        curso.setId(id);
        curso.setId_descricao(id_desc);
        if(cursomet.BuscaCursoseDescriçoesiguais(curso)){
                try {
                    cursomet.Alterar_Curso(curso);
                } catch (SQLException ex) {
                    Logger.getLogger(FormCursos.class.getName()).log(Level.SEVERE, null, ex);
                }
                JOptionPane.showMessageDialog(null, "Editado com sucesso!");
        }else{
            JOptionPane.showMessageDialog(null, "Curso ja existente.");
        }
        InicializaDadosEditar();
        jTF_cursonovo.setText("");
        jTF_descricaonovo.setText("");
        
    }else{
        JOptionPane.showMessageDialog(null, "Dados Incorretos!");
    }
}else{
    JOptionPane.showMessageDialog(null, "Dados não inseridos!");
}
}//GEN-LAST:event_buton_editarMouseClicked

    private void jTF_descricaoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_descricaoKeyReleased
         String inicial = jTF_descricao.getText();
          String maiuscula = "";  
    maiuscula = inicial.toUpperCase();
    jTF_descricao.setText(maiuscula);
    }//GEN-LAST:event_jTF_descricaoKeyReleased

    private void jTF_descricaonovoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTF_descricaonovoKeyReleased
        String inicial = jTF_descricaonovo.getText();
          String maiuscula = "";  
    maiuscula = inicial.toUpperCase();
    jTF_descricaonovo.setText(maiuscula);
    }//GEN-LAST:event_jTF_descricaonovoKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
       
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new FormCursos().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel buton_adicionar;
    private javax.swing.JLabel buton_deletar;
    private javax.swing.JLabel buton_editar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox jCB_curso;
    private javax.swing.JComboBox jCB_curso1;
    private javax.swing.JComboBox jCB_descricao;
    private javax.swing.JComboBox jCB_descricao1;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRB_adicionar;
    private javax.swing.JRadioButton jRB_deletar;
    private javax.swing.JRadioButton jRB_editar;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTF_cursonovo;
    private javax.swing.JTextField jTF_descricao;
    private javax.swing.JTextField jTF_descricaonovo;
    private javax.swing.JTextField jTF_nomecurso;
    private javax.swing.JLabel jl_curso;
    private javax.swing.JLabel jl_curso2;
    private javax.swing.JLabel jl_curso3;
    private javax.swing.JLabel jl_descricao;
    private javax.swing.JLabel jl_descricao2;
    private javax.swing.JLabel jl_descricao3;
    // End of variables declaration//GEN-END:variables

    private void DesabilitaAdicionar() {
        jl_curso.setVisible(false);
        jl_descricao.setVisible(false);
        buton_adicionar.setVisible(false);
        jTF_nomecurso.setVisible(false);
        jTF_descricao.setVisible(false);
    }
    
    private void DesabilitaEditar() {
        buton_editar.setVisible(false);
        jCB_curso.setVisible(false);
        jCB_descricao.setVisible(false);
        jTF_cursonovo.setVisible(false);
        jTF_descricaonovo.setVisible(false);
        jl_curso2.setVisible(false);
        jl_descricao2.setVisible(false);
    }

    private void DesabilitaDeletar() {
        buton_deletar.setVisible(false);
        jl_curso3.setVisible(false);
        jl_descricao3.setVisible(false);
        jCB_curso1.setVisible(false);
        jCB_descricao1.setVisible(false);
    }

    private void ChamaEscolha(String escolha) {
        if("Adicionar".equals(escolha)){
        jl_curso.setVisible(true);
        jl_descricao.setVisible(true);
        buton_adicionar.setVisible(true);
        jTF_nomecurso.setVisible(true);
        jTF_descricao.setVisible(true);
        }else if("Editar".equals(escolha)){
        buton_editar.setVisible(true);
        jCB_curso.setVisible(true);
        jCB_descricao.setVisible(true);
        jTF_cursonovo.setVisible(true);
        jTF_descricaonovo.setVisible(true);
        jl_curso2.setVisible(true);
        jl_descricao2.setVisible(true);

        }else if("Deletar".equals(escolha)){
         buton_deletar.setVisible(true); 
         jl_curso3.setVisible(true);
        jl_descricao3.setVisible(true);
        jCB_curso1.setVisible(true);
        jCB_descricao1.setVisible(true);
        }
    }

    private boolean VerificaDadosCorretosADD() {
        if("".equals(jTF_nomecurso.getText()) || "".equals(jTF_descricao.getText()) || !"A".equals(jTF_descricao.getText()) && !"B".equals(jTF_descricao.getText())&& !"C".equals(jTF_descricao.getText())&& !"D".equals(jTF_descricao.getText())&& !"E".equals(jTF_descricao.getText())&& !"F".equals(jTF_descricao.getText())&& !"G".equals(jTF_descricao.getText())&& !"H".equals(jTF_descricao.getText())){
            return false;
        }else {
            return true;
        }
    }

    private void limpaDadosAdicionar() {
        jTF_descricao.setText("");
        jTF_nomecurso.setText("");
    }

    private void InicializaDadosDeletar() {
        
        String[] cursos = cursomet.Buscar_Nome_Cursos();
        jCB_curso1.setModel(new javax.swing.DefaultComboBoxModel(cursos));
        String nome= jCB_curso1.getSelectedItem().toString();
        lista=cursomet.Buscar_Descricaolist(nome);
        String[] descrição = new String[lista.size()];
        for(int i = 0;lista.size()>i;i++){
        curso = lista.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao1.setModel(new javax.swing.DefaultComboBoxModel(descrição));
    }

    private void AtualizaDadosDeletar() {
        String nome= jCB_curso1.getSelectedItem().toString();
        lista=cursomet.Buscar_Descricaolist(nome);
        String[] descrição = new String[lista.size()];
        for(int i = 0;lista.size()>i;i++){
        curso = lista.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao1.setModel(new javax.swing.DefaultComboBoxModel(descrição));
    }

    private void InicializaDadosEditar() {
         String[] cursos = cursomet.Buscar_Nome_Cursos();
        jCB_curso.setModel(new javax.swing.DefaultComboBoxModel(cursos));
        String nome= jCB_curso.getSelectedItem().toString();
        lista=cursomet.Buscar_Descricaolist(nome);
        String[] descrição = new String[lista.size()];
        for(int i = 0;lista.size()>i;i++){
        curso = lista.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao.setModel(new javax.swing.DefaultComboBoxModel(descrição));
    }

    private void AtualizaDadosEditar() {
        String nome= jCB_curso.getSelectedItem().toString();
        lista=cursomet.Buscar_Descricaolist(nome);
        String[] descrição = new String[lista.size()];
        for(int i = 0;lista.size()>i;i++){
        curso = lista.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao.setModel(new javax.swing.DefaultComboBoxModel(descrição));
    }

    private boolean VerificaDadosCorretosEDT() {
        if("".equals(jTF_cursonovo.getText()) || "".equals(jTF_descricaonovo.getText())){
            return false;
        }
        else{
            return true;
        }
    }

    private boolean VerificaBD() {
        if(cursomet.Buscar_Se_Ha_Curso()){
        String[] cursos = cursomet.Buscar_Nome_Cursos();
        if(cursos.length==0){
            return false;
        }else{
            return true;
        }
    }else{
            return false;
        }
    }
    
}
